# NOTE: "gauche-package compile" doesn't handle C++ sources, so
# we have to write the rules for C++ files separately.

# General info
SHELL       = @SHELL@
prefix      = @prefix@
exec_prefix = @exec_prefix@
bindir      = @bindir@
libdir      = @libdir@
datadir     = @datadir@
datarootdir = @datarootdir@
srcdir      = @srcdir@
VPATH       = $(srcdir)

# These may be overridden by make invocators
DESTDIR        =
GOSH           = "@GOSH@"
GAUCHE_CONFIG  = "@GAUCHE_CONFIG@"
GAUCHE_PACKAGE = "@GAUCHE_PACKAGE@"
INSTALL        = "@GAUCHE_INSTALL@"

# Other parameters
SOEXT  = @SOEXT@
OBJEXT = @OBJEXT@
EXEEXT = @EXEEXT@

CXX      = @CXX@

# Module-specific stuff
PACKAGE   = mqueue-cpp

ARCHFILES = mqueue_cpp.$(SOEXT)
SCMFILES  = $(srcdir)/example/mqueue-cpp.scm
HEADERS   = 

TARGET    = $(ARCHFILES)
GENERATED = 
CONFIG_GENERATED = Makefile config.log $(PACKAGE).gpd

HEADER_INSTALL_DIR  = "$(DESTDIR)`$(GAUCHE_CONFIG) --siteincdir`"
SCM_INSTALL_DIR     = "$(DESTDIR)`$(GAUCHE_CONFIG) --sitelibdir`"
ARCH_INSTALL_DIR    = "$(DESTDIR)`$(GAUCHE_CONFIG) --sitearchdir`"

mqueue_SRCS = mqueue_lib.stub mqueue.cpp mqueue_glue.cpp
mqueue_HDRS = mqueue.h mqueue_glue.h

all : $(TARGET)

mqueue_cpp.$(SOEXT): $(mqueue_SRCS) $(mqueue_HDRS)
	$(GAUCHE_PACKAGE) compile --cc=$(CXX) --verbose mqueue_cpp $(mqueue_SRCS)

check : all
	@rm -f test.log
	$(GOSH) -I. test.scm > test.log

install : all
	$(INSTALL) -m 444 -T $(HEADER_INSTALL_DIR) $(HEADERS)
	$(INSTALL) -m 444 -T $(SCM_INSTALL_DIR) $(SCMFILES) 
	$(INSTALL) -m 555 -T $(ARCH_INSTALL_DIR) $(ARCHFILES)
	$(INSTALL) -m 444 -T $(SCM_INSTALL_DIR)/.packages $(PACKAGE).gpd

uninstall :
	$(INSTALL) -U $(HEADER_INSTALL_DIR) $(HEADERS)
	$(INSTALL) -U $(SCM_INSTALL_DIR) $(SCMFILES) 
	$(INSTALL) -U $(ARCH_INSTALL_DIR) $(ARCHFILES)
	$(INSTALL) -U $(SCM_INSTALL_DIR)/.packages $(PACKAGE).gpd

clean :
	$(GAUCHE_PACKAGE) compile --clean mqueue_cpp $(mqueue_SRCS)
	rm -rf core $(TARGET) $(GENERATED) *~ test.log so_locations

distclean : clean
	rm -rf $(CONFIG_GENERATED)

maintainer-clean : clean
	rm -rf $(CONFIG_GENERATED) VERSION

